package com.cbank.controller.homepage;

import com.cbank.domain.ModuleShow;
import com.cbank.service.ModuleShowService;
import com.cbank.vo.ModuleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/home/moduleshow")
public class ModuleShowController {
    @Autowired
    private ModuleShowService moduleShowService;

    /**
     * 获取单个模块下的轮播图与文章的信息
     * @param moduleId
     * @param model
     * @return
     */
    @RequestMapping("/")
    public String moduleShowByModuleId(@RequestParam(value = "moduleId")Integer moduleId, Model model){
        List<ModuleShow> imageList=this.moduleShowService.getListByModuleIdAndType(moduleId,ModuleShow.TYPE_GG);
        List<ModuleShow> moduleShowList=this.moduleShowService.getListByModuleIdAndType(moduleId,ModuleShow.TYPE_CON);
        ModuleVo moduleVo=new ModuleVo();
        moduleVo.setModuleShowList(moduleShowList);
        moduleVo.setImageList(imageList);
        model.addAttribute("moduleVo",moduleVo);
        return "";
    }
}
